using System;
using System.Collections;

namespace NGNntpPlugIn
{
	/// <summary>
	/// Summary description for NntpNewsgroupCollection.
	/// </summary>
	public class NntpNewsgroupCollection : IList
	{
		ArrayList m_nntpNewsgroups;

		public NntpNewsgroupCollection()
		{
			m_nntpNewsgroups = new ArrayList();
		}

		#region IList Members

		public bool IsReadOnly
		{
			get
			{
				return m_nntpNewsgroups.IsReadOnly;
			}
		}

		public object this[int index]
		{
			get
			{
				return m_nntpNewsgroups[index];
			}
			set
			{
				m_nntpNewsgroups[index] = value;
			}
		}

		public void RemoveAt(int index)
		{
			m_nntpNewsgroups.RemoveAt(index);
		}

		public void Insert(int index, object value)
		{
			m_nntpNewsgroups.Insert(index, value);
		}

		public void Remove(object value)
		{
			m_nntpNewsgroups.Remove(value);
		}

		public bool Contains(object value)
		{
			return m_nntpNewsgroups.Contains(value);
		}

		public void Clear()
		{
			m_nntpNewsgroups.Clear();
		}

		public int IndexOf(object value)
		{
			return m_nntpNewsgroups.IndexOf(value);
		}

		public int IndexOf(string newsgroupName)
		{
			int index = -1;

			for(int i=0; i<this.m_nntpNewsgroups.Count; i++)
			{
				NntpNewsgroup ng = (NntpNewsgroup) this.m_nntpNewsgroups[i];

				if(ng.Name.Trim().ToLower() == newsgroupName.Trim().ToLower())
				{
					index = i;
					break;
				}
			}

			return index;
		}

		public int Add(object value)
		{
			return m_nntpNewsgroups.Add(value);
		}

		public bool IsFixedSize
		{
			get
			{
				return m_nntpNewsgroups.IsFixedSize;
			}
		}

		#endregion

		#region ICollection Members

		public bool IsSynchronized
		{
			get
			{
				return m_nntpNewsgroups.IsSynchronized;
			}
		}

		public int Count
		{
			get
			{
				return m_nntpNewsgroups.Count;
			}
		}

		public void CopyTo(Array array, int index)
		{
			m_nntpNewsgroups.CopyTo(array, index);
		}

		public object SyncRoot
		{
			get
			{
				return m_nntpNewsgroups.SyncRoot;
			}
		}

		#endregion

		#region IEnumerable Members

		public IEnumerator GetEnumerator()
		{
			return m_nntpNewsgroups.GetEnumerator();
		}

		#endregion

		#region Public Methods

		public void ClearSelectedStatus()
		{
			foreach(NntpNewsgroup ng in m_nntpNewsgroups)
			{
				ng.IsSelected = false;
			}
		}

		#endregion
	}
}
